import http from './http.js'
/*
	url:地址
	method:请求方法
	data:请求参数
	context:有些请求路径不同，可以根据传值去重新更改，
	空代表不需要加mall根目录，默认添加mall目录
	0代表加不需要加mall根目录，走mallService根目录
	1代码请求图片的路径ip为8888
	callback:回调函数，执行请求后的业务逻辑
	
*/
function formatOptions(url, method, data, context, callback,fail) {
	let options = {
		url: url,
		method: method,
		data: data,
		context: context,
		callback: callback,
		fail:fail
	};
	http.request(options)
}
module.exports = {
	// 注册
	common:{
		register:(data, callback) => {
			formatOptions('/user/register', 'POST', data, 0, callback)
		},
		login:(data, callback) => {
			formatOptions('/user/login', 'POST', data, 0, callback)
		},
		editPassword:(data, callback) => {
			formatOptions('/user/findpwd', 'POST', data, 0, callback)
		},
		getQiNiuToken:(data, callback) => {
			formatOptions('/upload/token', 'GET', data, 0, callback)
		},
		sendCode:(data, callback) => {
			formatOptions('/api/v1/user/send', 'POST', data, 0, callback)
		},
		resetPwd:(data, callback) => {
			formatOptions('/api/v1/user/send/verify', 'POST', data, 0, callback)
		},
		
	},
	sellCar:{
		saveData:(data, callback,fail) => {
			formatOptions('/car', 'POST', data, 0, callback,fail)
		},
		editCar:(data, callback) => {
			formatOptions('/car/put/' + data, 'PUT', data, 0, callback)
		},
	},
	center:{
		star:(data, callback) => {
			formatOptions('/star', 'GET', data, 0, callback)
		},
		// release:(data, callback) => {
		// 	formatOptions('/car/all', 'GET', data, 0, callback)
		// },
		record:(data, callback) => {
			formatOptions('/record', 'GET', data, 0, callback)
		},
		// 已售出，草稿，已发布
		carStatus:(data, callback) => {
			
			formatOptions('/car', 'GET', data, 0, callback)
		},
		// 退出登陆
		loginOut:(data, callback) => {
			formatOptions('/user/logout', 'POST', data, 0, callback)
		},
		vipList:(data, callback) => {
			formatOptions('/dict/vip', 'GET', data, 0, callback)
		},
		pay:(data, callback) => {
			formatOptions('/user/vip', 'POST', data, 0, callback)
		},
		paySuccess:(data, callback) => {
			formatOptions('/pay/success', 'POST', data, 0, callback)
		},
		payFail:(data, callback) => {
			formatOptions('/pay/fail', 'POST', data, 0, callback)
		},
		isOpenVip:(data, callback) => {
			formatOptions('/open/auth', 'GET', data, 0, callback)
		},
		unCar:(data, callback) => {
			formatOptions('/car/off', 'POST', data, 0, callback)
		},
		
	},
	buyCar:{
		allVehicle:(data, callback) => {
			formatOptions('/car/all', 'GET', data, 0, callback)
		},
		carDetail:(data, callback) => {
			formatOptions('/car/detail', 'GET', data, 0, callback)
		},
		collect:(data, callback) => {
			formatOptions('/star', 'POST', data, 0, callback)
		},
		viewRecord:(data, callback) => {
			formatOptions('/record', 'POST', data, 0, callback)
		},
		getBrand:(data, callback) => {
			formatOptions('/store/car/brand', 'GET', data, 0, callback)
		},
		getFamily:(data, callback) => {
			formatOptions('/store/car/list', 'GET', data, 0, callback)
		},
		getVersion:(data, callback) => {
			formatOptions('/store/car/detail', 'GET', data, 0, callback)
		},
		sendPrice:(data, callback) => {
			formatOptions('/notice/dicker', 'POST', data, 0, callback)
		},
		buyNoticeList:(data, callback) => {
			formatOptions('/notice/buyNoticeList', 'POST', data, 0, callback)
		},
		dickerStatus:(data, callback) => {
			formatOptions('/notice/dickerStatus', 'POST', data, 0, callback)
		},
		
		
	},
	
	
	vehicleInfo:{},
	rate: 0,
	highSelectFormData: {},
	// 首页价格、品牌、车型关键词
	indexPriceSelect: {},
	indexBrandSelect: {},
	indexBodyTypeSelect: {},
	brandList:null,
	code:''

}
